﻿<html>
	<head>
		<link rel="stylesheet" href="http://localhost:8080/Anagram/css/css.css" type="text/css"; charset=UTF-8">
	</head>
	
	<body>
		<%@ page import="objects.*, java.util.*, dispatchers.*, util.*"%>
		<div id="main">
	
			<%@ include file="/jsp/general/header.jsp"%>
			<%@ include file="/jsp/general/mainmenu.html"%>

			<%! DBStatisticDispatcher statisticDispatcher = new DBStatisticDispatcher(new DBManager("anagram", "root", "root"), "games", "users");%>
			<%! int numberTop = 10;%>
			
			<% 
				String dateType = request.getParameter("dateType");
				if(dateType==null || !(dateType.equals("day") || dateType.equals("month") || dateType.equals("year") || dateType.equals("hour") || dateType.equals("minute")))
					dateType="DAY";
					
				int date=1;
				try{
					date = Integer.parseInt(request.getParameter("date"));
				}catch(NumberFormatException e){}
				
				List<String[]> list = statisticDispatcher.getTop(numberTop, date, dateType); 
			%>
			
			
			<div id="article">
				<caption>
					Топ <%= numberTop %> игроков
				</caption>
				<table>
					<tr>
						<th align="right">имя: &nbsp&nbsp<th>набранные очки
					</tr>
					
					<%for(int i=0; i<list.size(); i++){%>
						<tr>
							<td align="right"><%= list.get(i)[0]%> &nbsp&nbsp<td><%= list.get(i)[1]%> &nbsp&nbsp<td><%= list.get(i)[2]%>
						</tr>
					<%}%>
				</table>
				
				<br>Статистика:
				<a href="http://localhost:8080/Anagram/jsp/statistic/statistic.jsp?dateType=minute">за минуту</a>&nbsp&nbsp
				<a href="http://localhost:8080/Anagram/jsp/statistic/statistic.jsp?dateType=hour">за час</a>&nbsp&nbsp
				<a href="http://localhost:8080/Anagram/jsp/statistic/statistic.jsp?dateType=day">за день</a>&nbsp&nbsp
				<a href="http://localhost:8080/Anagram/jsp/statistic/statistic.jsp?dateType=day&date=7">за неделю</a>&nbsp&nbsp
				<a href="http://localhost:8080/Anagram/jsp/statistic/statistic.jsp?dateType=month">за месяц</a>&nbsp&nbsp
				<a href="http://localhost:8080/Anagram/jsp/statistic/statistic.jsp?dateType=year">за год</a>&nbsp&nbsp
				
			</div>
			
			
			<%@ include file="statisticmenu.html"%>
			
			<%@ include file="/jsp/general/bottom.jsp"%>
		</div>
		
	</body>
</html>